#include "command.h"

int _rmdir(char *argv[])
{
	/* check the number of cmd-line parameters is correct */
	int argc = 0;
	for (char **ptr = argv; *ptr != NULL; ptr++)
		argc++;

	if (argc < 2) {
		fprintf(stderr, "Usage: rmdir dir1, dir2, ...\n");
		return -1;
	}

	/* remove the empty directory */
	const char *dir_name;
	for (int i = 1; i < argc; i++) {
		dir_name = argv[i];
		if (rmdir(dir_name) == -1) {
			fprintf(stderr, "rmdir error: rmdir\n");
			return -1;
		}
	}

	return 0;
}
